package com.dycx.api.controller.app;

import com.dycx.common.RestResponse;
import com.dycx.payment.service.PaymentOrderService;
import com.dycx.system.service.AppVersionService;
import com.dycx.system.vo.AppVersionVO;
import com.dycx.user.service.UserInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping(value = "/app/index")

public class IndexController {
    @Resource
    private AppVersionService appVersionService;

    @Resource
    private PaymentOrderService paymentOrderService;

    @Resource
    private UserInfoService userInfoService;

    /**
     * app版本
     **/
    @GetMapping("test")
    public RestResponse<String> test() {
       return RestResponse.fail("546565000111122233334444555");
    }


    /**
     * app版本
     **/
    @GetMapping("getAppNewVersion")
    public RestResponse<AppVersionVO> getAppNewVersion(int appId) {
        return RestResponse.success(appVersionService.getNew(appId));
    }

//    public RestResponse<?> getNewPayLog() {
//        List<Map<String,String>> result = new ArrayList<>();
//
//        LambdaQueryWrapper<PaymentOrderDO> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(PaymentOrderDO::getResult, true);
//        wrapper.orderByDesc(PaymentOrderDO::getPayOrderId);
//        wrapper.last("limit 10");
//
//        List<PaymentOrderDO> payList = paymentOrderService.list(wrapper);
//        payList.forEach(item->{
//            UserInfoVO vo = userInfoService.load(item.getUid());
//
//            Map<String,String> map = new HashMap<>();
//            map.put("avatar",vo.getAvatar());
//            map.put("content","["+vo.getNickname()+"] 2小时前购买了1个月会员")
//
//
//        });
//
//
//    }
}

